import request from '@/utils/request'

const repository = 'b/gameDataController'
const mpApi = {
    pageGameJoin: repository + '/pageGameJoin',
    pageTrack: repository + '/pageTrack',
    todayMap: repository + '/todayMap',
    yesterdayMap: repository + '/yesterdayMap',
    totalMap: repository + '/totalMap',
    gameCircleData: repository + '/gameCircleData',
    fissionLevel: repository + '/fissionLevel',
    listGameDetail: repository + '/listGameDetail',
    listByGameAward: repository + '/listByGameAward',
    exportGameList: repository + '/exportGameList',
    redeem: repository + '/redeem',
    gameCount: repository + '/gameCount'
}

export function gameCount (gameId, gzhUserId) {
    return request({
        url: mpApi.gameCount,
        params: {
            gameId,
            gzhUserId
        }
    })
}

export function pageTrack (gzhUserId, gameId, fromOpenId, query) {
    return request({
        url: mpApi.pageTrack,
        method: 'get',
        params: {
            gameId,
            gzhUserId,
            fromOpenId,
            query
        }
    })
}

export function todayMap (parameter) {
    return request({
        url: mpApi.todayMap,
        params: parameter
    })
}

export function pageGameJoin (query, { gzhUserId, gameId, appId, nickname, onlyBlocked }) {
    return request({
        url: mpApi.pageGameJoin,
        params: {
            query: JSON.stringify(query),
            search: JSON.stringify({
                keyword: nickname,
                k2: gameId,
                k3: onlyBlocked,
                k4: appId,
                k5: gzhUserId
            })
        }
    })
}

export function yesterdayMap (parameter) {
    return request({
        url: mpApi.yesterdayMap,
        params: parameter
    })
}

export function totalMap (parameter) {
    return request({
        url: mpApi.totalMap,
        params: parameter
    })
}

export function gameCircleData (parameter) {
    return request({
        url: mpApi.gameCircleData,
        params: parameter
    })
}

export function listGameDetail (parameter) {
    return request({
        url: mpApi.listGameDetail,
        params: parameter
    })
}

export function fissionLevel (parameter) {
    return request({
        url: mpApi.fissionLevel,
        params: parameter
    })
}

export function listByGameAward (gameId, gzhUserId) {
    return request({
        url: mpApi.listByGameAward,
        method: 'get',
        params: {
            gameId,
            gzhUserId
        }
    })
}

export function exportGameList (gameId, mpId, level, state, gzhUserId) {
    return request({
        url: mpApi.exportGameList,
        method: 'get',
        params: {
            gameId,
            mpId,
            level,
            state,
            gzhUserId
        }
    })
}

export function redeem (joinIds, awardId, gzhUserId) {
    return request({
        url: mpApi.redeem,
        method: 'get',
        params: {
            joinIds: joinIds,
            awardId: awardId,
            gzhUserId: gzhUserId
        }
    })
}

export default {
    pageGameJoin,
    pageTrack,
    todayMap,
    yesterdayMap,
    totalMap,
    gameCircleData,
    fissionLevel,
    listGameDetail,
    listByGameAward,
    exportGameList,
    redeem,
    gameCount

}
